






//
//  NUserModel.m
//  nncloud
//
//  Created by 朵 on 2018/9/23.
//  Copyright © 2018年 youedata. All rights reserved.
//  NSUnknownKeyException', reason: '[<NUserModel 0x1c40b8ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key userInfoUrl.'
//后台返回的字段多于我们写的字段，这时候要加上下面那个  forUndefinedKey  的方法才可以

#import "NUserModel.h"
#import <MJExtension/MJExtension.h>


@implementation NUserModel

+(instancetype)shareInstance{
    static NUserModel *_userModel = nil;
    static dispatch_once_t t;
    dispatch_once(&t,^{
        _userModel = [[NUserModel alloc]init];
    });
    return _userModel;
}

///防止后台返回的字段不对应或多或少    引起的crash
-(void)setValue:(id)value forUndefinedKey:(nonnull NSString *)key{
    
    
}


+(void)saveUserInfoWithDic:(NSDictionary *)dic{

//    NSDictionary *dict = [dic deleteNull];
    
    [self saveData:dic];
    
}

+(void)cleanUserInfo{
    
     [NUserModel shareInstance].userInfoId = nil;
     [NUserModel shareInstance].userInfoName = nil;
     [NUserModel shareInstance].userInfoCreateTime = nil;
     [NUserModel shareInstance].userInfoSalt = nil;
     [NUserModel shareInstance].userInfoStatus = nil;
     [NUserModel shareInstance].userInfoNickname = nil;
     [NUserModel shareInstance].userInfoUpdateTime = nil;
     [NUserModel shareInstance].userInfoNamePwd = nil;
     [NUserModel shareInstance].userInfoType = nil;
    [NUserModel shareInstance].userInfoTel = nil;
    [NUserModel shareInstance].userInfoCertificationStatus = nil;
    [NUserModel shareInstance].userInfoCertificationType = nil;
    [NUserModel shareInstance].userInfoLatestTime = nil;
     [self saveData:nil];
    
}

+ (void)saveData:(NSDictionary *)data{
    
    
    [[NSUserDefaults standardUserDefaults] setObject:[data deleteNull] forKey:kSaveUserInfoKey];
    YYLog(@"%@",[data deleteNull]);
    [[NSUserDefaults standardUserDefaults] synchronize];
}



@end
